package Homework2

import scala.beans.BeanProperty
import scala.util.Random

class Computer {
  @BeanProperty var name: String = _
  @BeanProperty var choice: String = _
  @BeanProperty var win: Int = _
  @BeanProperty var draw: Int = _
  @BeanProperty var loss: Int = _

  def showFist(): Int = {
    val fist: String = Computer.fist(Random.nextInt(Computer.fist.length))
    println(name + "出拳:" + fist)
    fist match {
      case "剪刀" => 1
      case "石头" => 2
      case "布" => 3
    }
  }

  override def toString: String = {
    getName + " " + (getWin * 2 + getDraw) + " " + getWin + " " + getDraw + " " + getLoss
  }
}

object Computer{
  val fist: Array[String] = Array("剪刀", "石头", "布")
}
